package com.sky.mapper;

import com.github.pagehelper.Page;
import com.sky.annotation.AutoFill;
import com.sky.dto.DishPageQueryDTO;
import com.sky.entity.Dish;
import com.sky.entity.DishFlavor;
import com.sky.enumeration.OperationType;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;

@Mapper
public interface DishMapper {

    /**
     * 根据分类id查询菜品数量
     * @param categoryId
     * @return
     */
    @Select("select count(id) from dish where category_id = #{categoryId}")
    Integer countByCategoryId(Long categoryId);


    /*
    * 插入菜品数据
    * */
    @AutoFill(OperationType.INSERT)
    void insert(Dish dish);

    /*
     * 根据id查询菜品
     * @param id
     * */
    @Select("select * from dish where id = #{id}")
    Dish getById(Long id);



    /*
     * 修改菜品
     * @param Dish
     * */
    @AutoFill(OperationType.UPDATE)
    void update(Dish dish);


    /*
    批量查询菜品
    * */
    List<Dish> selectBatch(List<Long> ids);


    /*
    * 批量删除菜品
    * */
    void deleteBatch(List<Long> ids);

    /*
     * 菜品分页查询
     * @param dishPageQueryDTO
     * */
    Page<Dish> pageQuery(DishPageQueryDTO dishPageQueryDTO);


    /*
    * 动态条件查询菜品
    * @param dish
    * */
    List<Dish> list(Dish dish);
}
